Lecture #5 – Parts of your first program
Published on: Thu Feb 04 2010
Include Files
- Pull what is necessary from included library’s and inserts into Binary
Standard Libraries
- Math and Standard Operations
The Preprocessor (More on this in CSE 230)
- Strips our Comments
- Makes substitutions for named constants
- insert definition of included function files (Reserves space for them)
Every C Program must have a main function
int main (void)
- Execution begins and ends with the main function
- Program Statements are executed sequentially
- Execution begins at first statement of main
- ( ) are used to specific function parameters
- { } enclose the body, are used to group statements
- If you do not declare int main you do not need to end with return 0;
- n means “go to the next line”
- backslash key is an escape character
- t means tab
- return 0; - Signals successful end of your program to the operating system
- Many functions return values, ie: Mathematical functions
Program Structure
- Preprocessor directives
- #include-d files
- Other definitions/Declarations
- Supporting functions
- Main functions
Variables are named blocks of memory
Intergers
Regular int = 4 bytes
Short int = 2 bytes
Floating Points
Float = 4 bytes (standard accuracy, 8 digits after decimal)
Double = 8 bytes (better accuracy, more decimals)
Char – 1 byte
Every memory block has a # and your var is assigned a # (by Preprocessor?)